package com.qhhj.hengold.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * adapter 基类
 * Created by admin on 2016/6/27.
 */
public abstract class AppBaseAdater<T> extends BaseAdapter {

    public List<T> mList = null;
    public Context mContext = null;
    public LayoutInflater mInflater = null;


    public AppBaseAdater(List<T> mList, Context mContext) {
        this.mList = mList;
        this.mContext = mContext;
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return mList != null && mList.size() > 0 ? mList.size() : 0;
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        return getItemView(i, view, viewGroup);
    }

    /**
     * @param i
     * @param view
     * @param viewGroup
     * @return
     */
    public abstract View getItemView(int i, View view, ViewGroup viewGroup);


//    public class SupperViewHolder {
//        public View itemView;
//
//        public SupperViewHolder(int resLayoutId, ViewGroup parent) {
//            itemView = mInflater.inflate(resLayoutId, parent, false);
//            itemView.setTag(this);
//        }
//    }
}
